import type { Request, ResponseToolkit } from "@hapi/hapi";
import Hapi from "@hapi/hapi";
import { User } from "../../model/index";
interface user {
  account: string;
  password: string;
  _id: string;
}
let route: Hapi.ServerRoute<Hapi.ReqRefDefaults> = {
  path: "/getUserInfo",
  method: "get",
  handler: async (r: any, h: ResponseToolkit) => {
    try {
      const user: user | null = await User.findOne({ _id: r.userId });
      return { code: 200, data: user, message: "" };
    } catch (error) {
      return error;
    }
  },
  options: {
    tags: ["api"],
  },
};
export default route;
